﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using VK.Comm;
using VK.Casemeet.Slides;

namespace VK.Casemeet.Web.Admin.Slides
{
    public partial class SlideAdd : System.Web.UI.Page
    {
        public string imgUrl = "Null.jpg";

        protected void Page_Load(object sender, EventArgs e)
        {
            (this.Master as Site).SiteMapPathControl.MapPathList = new List<MapPath>(){
                new MapPath{ Text="桌面",Url="/Admin/Home.aspx"},
                new MapPath{ Text="焦点图列表",Url="/Admin/Slides/SlideList.aspx"},
                new MapPath{ Text="新增",Url="#"}
            };

            if (!IsPostBack)
            {
                
            }
        }

        protected void butSave_Click(object sender, EventArgs e)
        {
            SlideEntity slide = LoadEntity();

            if (SlideBLL.InsertSlide(slide) > 0)
            {
                Message.Msg(this.Page, CS.MsgAddSuccess, MessageType.Success);
                Util.ClearControl((this.Master as Site).contentBody.Controls);
            }
            else
            {
                Message.Msg(this.Page, CS.MsgAddFailure, MessageType.Failure);
            }
        }

        protected SlideEntity LoadEntity()
        {
            SlideEntity slide = new SlideEntity();
            //slide.Explain = txtExplain.Text;
            //slide.Width = int.Parse(txtWidth.Text);
            //slide.Height = int.Parse(txtHeight.Text);
            //slide.Created = DateTime.Now;
            //string[] imgUrlArray = new JavaScriptSerializer().Deserialize<string[]>(Util.GetFormString("hidImgUrlArray"));
            //slide.ImgUrllst = new List<string>(imgUrlArray);

            return slide;
        }
    }
}